<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 创建类 class 创建一个明星类 es6
      class Star {
        constructor(uname, age) {
          this.uname = uname;
          this.age = age;
        }
        sing(song) {
          //   console.log("顶顶顶");
          console.log(this.uname + song);
        }
      }
      // 利用类创建对象 new
      var ldh = new Star("刘德华", 20);
      var zxy = new Star("张学友", 20);
      console.log(ldh);
      console.log(zxy);
      //   类里面所有的函数不需要写function
      ldh.sing("kk");
      zxy.sing("ll");
    </script>
  </body>
</html>
